Make it possible to encode a portion of the buffer#7
Closed
dfahlander wants to merge 1 commit intoniklasvh:masterfrom
Closed
Make it possible to encode a portion of the buffer#7dfahlander wants to merge 1 commit intoniklasvh:masterfrom
dfahlander wants to merge 1 commit intoniklasvh:masterfrom
Conversation
If you want to encode a TypedArray, such as a Float64Array, Uint16Array or so, it can be backed by just a portion of an ArrayBuffer. If wanting to encode such a TypedArray without having to copy the portion into a new buffer, the encode function should take an offset and a length. Example ```js var buffer = new ArrayBuffer(65536); ...fill buffer with something... // Create a Uint16 view of bytes [1024...2047]: var array = new Uint16Array(buffer, 1024, 512); // 512 = length in 16-bit units. encode (array.buffer, array.byteOffset, array.byteLength); ```
|
Any chance of getting this pulled? This line: var bytes = new Uint8Array(arraybuffer, offset || 0, length !== undefined ? length : arraybuffer.byteLength),could be simplified, however, to: var bytes = new Uint8Array(arraybuffer, offset, length),as per https://tc39.github.io/ecma262/#sec-typedarray-buffer-byteoffset-length which references the ToIndex abstract operation indicating that if the byte offset is |
brettz9
added a commit
to brettz9/base64-arraybuffer
that referenced
this pull request
Feb 17, 2017
replacement for PR niklasvh#7 by relying on ES defaults
Author
|
This PR is replaced by #8. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If you want to encode a TypedArray, such as a Float64Array, Uint16Array or so, it can be backed by just a portion of an ArrayBuffer. If wanting to encode such a TypedArray without having to copy the portion into a new buffer, the encode function should take an offset and a length.
Example